Using Core Printing Features
This section shows how to implement the core printing features in your application First, you must determine if QuickDraw GX is installed and, if so, set up its environment. Next, when the user creates a document, your application needs to create a job object for the document and maintain other information about the document. The sample code throughout this book uses a structure,MyDocumentRec
, to keep the needed information in one place:
typedef struct MyDocumentRec { gxJob documentJob; /* the job object bound to the document */ long numPages; /* the number of pages in the document */ long curPage; /* the current page */ FSSpec documentFSSpec; /* the file system specification for the document */ Str31 documentTitle /* the title of the document (such as "Untitled") */ WindowPtr documentWindow; /* the window for the document */ gxViewPort documentViewPort; /* the view port used for drawing within the document window */ gxShape documentPage[kMaxPages]; /* the shape data for each page */ gxFormat pageFormat[kMaxPages]; /* the format object for each page, if nil use the default format */ } MyDocumentRec, *MyDocumentPtr;This structure is set up to handle one shape per page. Each page may have its own format, although in this chapter only one format is used. The individual fields in the structure are described as they are used in the following sections.Your application could define a similar structure, or you could maintain the needed information in variables of your choosing. The variable used in this book is myDocument, which is defined as follows:
MyDocumentRec myDocument;The following sections show how to
- initialize QuickDraw GX printing
- create a job object and initialize the myDocument variable
- handle errors
- print a document
- save a job object by flattening it
- retrieve a job object by unflattening it
- dispose of a job object and the objects it references
- obtain format information
- support print dialog boxes
- perform printing from the Finder
- update job object information after resume events
- print existing documents designed for printing with the Macintosh Printing Manager
Subtopics
- Initializing QuickDraw GX Printing
- Creating a Job Object for a Printable Document
- Error Handling
- Supporting QuickDraw GX Print Dialog Boxes
- Printing Documents Using QuickDraw GX
- Saving a Job Object With a Document File
- Disposing of a Job Object When Closing a Document
- Retrieving a Job Object When Opening a Document
- Obtaining Object References
- Obtaining Information From a Format Object
- Displaying QuickDraw GX Print Dialog Boxes
- Supporting Printing From the Finder
- Updating Job Object Information
- Printing Macintosh Printing Manager Documents
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help